import { v4 as uuidv4 } from 'uuid'

export const getUserTempId = function () {
  const userTempId = localStorage.getItem('userTempId')
  if (userTempId) {
    return userTempId
  } else {
    const newUserTempId = uuidv4()
    localStorage.setItem('userTempId', uuidv4())
    return newUserTempId
  }
}

/**
 * @des 将 token 存储到本地
 * @param {*} token
 */

export const setToken = (token: string) => {
  localStorage.setItem('token', token)
}

/**
 * @des 获取本地 存储 token
 * @param {*} token
 */

export const getToken = () => {
  return localStorage.getItem('token')
}
